/**
 *
 */
package com.monkeyboy.controller;

import com.monkeyboy.common.exception.GlobalException;
import com.monkeyboy.common.dto.ResData;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 *
 * @author Gavin<br>
 *         2019年8月24日
 */
@RestControllerAdvice
public class ControllerExceptionHandler {
    @ExceptionHandler(GlobalException.class)
    public ResData handleGlobalException(GlobalException ex) {
        return ResData.ERROR_500000(ex.getMessage());
    }

    @ExceptionHandler(AccessDeniedException.class)
    public ResData handleGlobalException(AccessDeniedException ex) {
        return ResData.ERROR_500000("无权限访问");
    }

    @ExceptionHandler(Exception.class)
    public ResData handleException(Exception ex) {
        ex.printStackTrace();
        return ResData.ERROR_500("网络繁忙，请稍后重试。");
    }
}
